{% extends "base.html" %}

{% block head-title %}{{algorithm.algorithm_name}}{% endblock %}

{% block title %}{{algorithm.algorithm_name}}{% endblock %}

{% block content %}
<div style="float: right;">
	<a href="/static/{{algorithm.instance_id}}/{{algorithm.data_source_name}}"
		class="uk-button uk-button-success" target="_blank" download="{{algorithm.data_source_name}}">数据文件</a>
	<a href="/show_source_code?instance_id={{algorithm.instance_id}}"
		class="uk-button uk-button-primary" target="_blank">源代码</a>
</div>
{% if algorithm.algorithm_name != "深度学习-图像识别" %}
<h2>数据源</h2>
<table class="uk-table uk-table-striped">
	<caption>记录数:{{algorithm.data_source_size}}</caption>
	<thead>
		<tr>
			<th>序号</th> 
			{% for column in algorithm.data_source.columns %}
			<th>{{ column }}</th> 
			{% endfor %}
		</tr>
	</thead>
	<tbody>
		{% for values in algorithm.data_source.head.values %}
		<tr>
			<td>{{ forloop.counter }}</td>
			{% for value in values%}
			<td>{{ value }}</td>
			{% endfor %}
		</tr>
		{% endfor %}
	</tbody>
</table>
<hr />
{% endif %}

<h2>模型</h2>
<table class="uk-table uk-table-striped">
	<thead>
		<tr>
			<th>项目</th>
			<th>内容</th>
		</tr>
	</thead>
	<tbody>
		{% if algorithm.algorithm_name == "深度学习-二分类" or algorithm.algorithm_name == "深度学习-多分类" or algorithm.algorithm_name == "深度学习-回归" %}
		<tr>
			<td>输入字段</td>
			<td>{{ algorithm.input_field_names|join:"|" }}</td>
		</tr>
		<tr>
			<td>输出字段</td>
			<td>{{ algorithm.output_field_name }}</td>
		</tr>
		<tr>
			<td>神经网络结构</td>
			<td>{% autoescape off %}{{ algorithm.model_summary }}{% endautoescape %}</td>
		</tr>
		<tr>
			<td>优化函数</td>
			<td>{{ algorithm.optimizer }}</td>
		</tr>
		<tr>
			<td>训练周期</td>
			<td>{{ algorithm.epochs }}</td>
		</tr>
		<tr>
			<td>批次大小</td>
			<td>{{ algorithm.batch_size }}</td>
		</tr>
		{% endif %}
		{% if algorithm.algorithm_name == "深度学习-二分类" or algorithm.algorithm_name == "深度学习-多分类" %}
		<tr>
			<td>训练集准确率(0~1)</td>
			<td>{{ algorithm.test_score | floatformat:2 }}</td>
		</tr>
		<tr>
			<td>测试集准确率(0~1)</td>
			<td>{{ algorithm.train_score | floatformat:2 }}</td>
		</tr>
		<tr>
			<td>准确度收敛情况</td>
			<td>
				<a href="/static/{{algorithm.instance_id}}/chart/accuracy.png" target="_blank" title="点击查看大图">
					<img src="/static/{{algorithm.instance_id}}/chart/accuracy.png" style="height:300px;">
				</a>
			</td>
		</tr>
		<tr>
			<td>损失函数收敛情况</td>
			<td>
				<a href="/static/{{algorithm.instance_id}}/chart/loss_value.png" target="_blank" title="点击查看大图">
					<img src="/static/{{algorithm.instance_id}}/chart/loss_value.png" style="height:300px;">
				</a>
			</td>
		</tr>
		{% endif %}
		{% if algorithm.algorithm_name == "深度学习-回归" %}
		<tr>
			<td>训练集MSE</td>
			<td>{{ algorithm.test_score | floatformat:2 }}</td>
		</tr>
		<tr>
			<td>测试集MSE</td>
			<td>{{ algorithm.train_score | floatformat:2 }}</td>
		</tr>
		<tr>
			<td>损失函数收敛情况</td>
			<td>
				<a href="/static/{{algorithm.instance_id}}/chart/loss_value.png" target="_blank" title="点击查看大图">
					<img src="/static/{{algorithm.instance_id}}/chart/loss_value.png" style="height:300px;">
				</a>
			</td>
		</tr>
		{% endif %}
		
		{% if algorithm.algorithm_name == "深度学习-LSTM" %}
		<tr>
			<td>序列值字段</td>
			<td>{{ algorithm.in_out_put_filed_name }}</td>
		</tr>
		<tr>
			<td>神经网络结构</td>
			<td>{% autoescape off %}{{ algorithm.model_summary }}{% endautoescape %}</td>
		</tr>
		<tr>
			<td>训练周期</td>
			<td>{{ algorithm.epochs }}</td>
		</tr>
		<tr>
			<td>下一周期预测</td>
			<td>{{ algorithm.output_y }}</td>
		</tr>
		<tr>
			<td>训练集RMSE</td>
			<td>{{ algorithm.train_score }}</td>
		</tr>
		<tr>
			<td>测试集RMSE</td>
			<td>{{ algorithm.test_score }}</td>
		</tr>
		<tr>
			<td>损失函数</td>
			<td>
				<a href="/static/{{algorithm.instance_id}}/chart/loss_value.png" target="_blank" title="点击查看大图">
					<img src="/static/{{algorithm.instance_id}}/chart/loss_value.png" style="height:300px;">
				</a>
			</td>
		</tr>
		<tr>
			<td>训练集</td>
			<td>
				<a href="/static/{{algorithm.instance_id}}/chart/train.png" target="_blank" title="点击查看大图">
					<img src="/static/{{algorithm.instance_id}}/chart/train.png" style="height:300px;">
				</a>
			</td>
		</tr>
		<tr>
			<td>测试集</td>
			<td>
				<a href="/static/{{algorithm.instance_id}}/chart/test.png" target="_blank" title="点击查看大图">
					<img src="/static/{{algorithm.instance_id}}/chart/test.png" style="height:300px;">
				</a>
			</td>
		</tr>
		{% endif %}
		
		{% if algorithm.algorithm_name == "深度学习-图像识别" %}
		<tr>
			<td>图像</td>
			<td>
				<a href="/static/{{algorithm.instance_id}}/{{algorithm.data_source_name}}" target="_blank" title="点击查看大图">
					<img src="/static/{{algorithm.instance_id}}/{{algorithm.data_source_name}}" style="height:300px;">
				</a>
			</td>
		</tr>
		<tr>
			<td>ResNet50</td>
			<td><span style="color:blue;">{{ algorithm.label_resnet }}</span>&nbsp;(概率:{{algorithm.possible_resnet}})</td>
		</tr>
		<tr>
			<td>MobileNet</td>
			<td><span style="color:blue;">{{ algorithm.label_mobilnet }}</span>&nbsp;(概率:{{algorithm.possible_mobilnet}})</td>
		</tr>
		<tr>
			<td>InceptionV3</td>
			<td><span style="color:blue;">{{ algorithm.label_inception }}</span>&nbsp;(概率:{{algorithm.possible_inception}})</td>
		</tr>
		{% endif %}
		
	</tbody>
</table>
<hr />

{% if algorithm.algorithm_name == "深度学习-二分类" or algorithm.algorithm_name == "深度学习-多分类" or algorithm.algorithm_name == "深度学习-回归" %}
<h2>预测</h2>
<table class="uk-table uk-table-striped">
	<thead>
		<tr>
			<th>序号</th>
			{% for name in predict_column_names %}
			<th>{{ name }}</th> 
			{% endfor %}
		</tr>
	</thead>
	<tbody>
		{% for values in predict_values %}
		<tr>
			<td>{{ forloop.counter }}</td>
			{% for value in values%}
			<td>{{ value }}</td>
			{% endfor %}
		</tr>
		{% endfor %}
	</tbody>
</table>
{% endif %}

{% endblock %}